package cn.gok.hotelback.mapper;

import cn.gok.hotelback.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {
    @Select("SELECT * FROM users WHERE username = #{username}")
    User findByUsername(@Param("username") String username);
    
    @Insert("INSERT INTO users (username, password, real_name, phone, id_card, balance, level) VALUES (#{username}, #{password}, #{realName}, #{phone}, #{idCard}, #{balance}, #{level})")
    int insertUser(User user);
    @Select("SELECT * FROM users WHERE level < 9")
    java.util.List<User> findAllMembers();
    @Update("UPDATE users SET level = #{level} WHERE user_id = #{userId}")
    int updateUserLevel(@Param("userId") Integer userId, @Param("level") Integer level);

    @Select("SELECT * FROM users WHERE user_id = #{userId}")
    User findById(@Param("userId") Integer userId);
} 